package oop.utilPackage;

import javax.xml.crypto.Data;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;

public class Example {

    public static void getAge(Date birth){


        Date date = new Date();

        int nowYear = date.getYear()+1900;

        int birthYear = birth.getYear();

        System.out.println(nowYear - birthYear);


    }

    public static void getAge(String birth) throws ParseException {
//        String[] ymd = birth.split("[-/~]");
//        int birthYear = Integer.parseInt(ymd[0]);

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date birthDate = sdf.parse(birth);
        int birthYear = birthDate.getYear()+1900;


        Date date = new Date();
        int nowYear = date.getYear()+1900;

        System.out.println(nowYear-birthYear);
    }

    public static void main(String[] args) throws ParseException {
        Example.getAge("2000-01-01");
    }
}
